from pydantic import BaseModel, Field
from typing import List, Dict, Any, Optional


class BasicUserInfo(BaseModel):
    """基础用户信息"""
    id: str = Field(description="用户ID")
    nickname: str = Field(description="用户昵称")
    avatar: Optional[str] = Field(default=None, description="头像")
    link: Optional[str] = Field(default=None, description="用户链接")

class AtUserInfo(BaseModel):
    """@用户信息"""
    id: str = Field(description="用户ID")
    nickname: str = Field(description="用户昵称")
    link: Optional[str] = Field(default=None, description="用户链接")

class SearchNote(BaseModel):
    """搜索笔记"""
    id: Optional[str] = Field(default=None, description="笔记ID")
    link: Optional[str] = Field(default=None, description="笔记链接")
    title: Optional[str] = Field(default=None, description="笔记标题")
    cover_image: Optional[str] = Field(default=None, description="笔记封面")
    type: Optional[str] = Field(default=None, description="笔记类型")
    likes: Optional[int] = Field(default=None, description="点赞数")
    user: Optional[BasicUserInfo] = Field(default=None, description="用户信息")

class NotesResult(BaseModel):
    """笔记列表结果"""
    notes: List[SearchNote] = Field(description="搜索笔记列表")
    total: int = Field(description="总数")
    cursor: Optional[str] = Field(default=None, description="下一页游标")
    has_more: bool = Field(default=False, description="是否有更多")



class NoteDetail(BaseModel):
    """笔记详情"""
    id: Optional[str] = Field(default=None, description="笔记编号")
    link: Optional[str] = Field(default=None, description="笔记链接")
    type: Optional[str] = Field(default=None, description="笔记类型")
    title: Optional[str] = Field(default=None, description="笔记标题")
    content: Optional[str] = Field(default=None, description="笔记内容")
    cover_image: Optional[str] = Field(default=None, description="笔记封面")
    images: Optional[List[str]] = Field(default=None, description="图片列表")
    likes: Optional[str] = Field(default=None, description="点赞数")
    comments: Optional[str] = Field(default=None, description="评论数")
    collects: Optional[str] = Field(default=None, description="收藏数")
    shares: Optional[str] = Field(default=None, description="分享数")
    time: Optional[str] = Field(default=None, description="时间")
    last_update_time: Optional[str] = Field(default=None, description="最后更新时间")
    video_link: Optional[str] = Field(default=None, description="视频链接")
    user: Optional[BasicUserInfo] = Field(default=None, description="作者信息")
    tags: Optional[List[str]] = Field(default_factory=list, description="标签列表")
    ip_location: Optional[str] = Field(default=None, description="IP地址")
    illegal_info: Optional[str] = Field(default=None, description="违规信息")
    at_user_list: Optional[List[AtUserInfo]] = Field(default=None, description="@用户列表")




class UserInfo(BaseModel):
    """用户信息"""
    user_id: str = Field(description="用户ID")
    nickname: str = Field(description="用户昵称")
    # ... 其他用户信息字段 

class Hots(BaseModel):
    """热点榜单"""
    title: Optional[str] = Field(default=None, description="标题")
    score: Optional[str] = Field(default=None, description="热度值")
    word_type: Optional[str] = Field(default=None, description="类型")
    rank_change: Optional[str] = Field(default=None, description="排名变化")

class HotsResult(BaseModel):
    """热点榜单结果"""
    timestamp: str = Field(description="时间")
    data: List[Hots] = Field(description="热点榜单列表")


class CommentInfo(BaseModel):
    """评论信息"""
    comment_id: str = Field(description="评论ID")
    content: str = Field(description="评论内容")
    user_id: str = Field(description="评论用户ID")
    nickname: str = Field(description="评论用户昵称")
    time: str = Field(description="评论时间")
    like_count: int = Field(description="点赞数")
    sub_comment_count: int = Field(description="子评论数")

class CommentResult(BaseModel):
    """评论结果"""
    comments: List[CommentInfo] = Field(description="评论列表")
    total: int = Field(description="总数")
    cursor: Optional[str] = Field(default=None, description="下一页游标")
    has_more: bool = Field(default=False, description="是否有更多")

class SubCommentInfo(BaseModel):
    """子评论信息"""
    root_comment_id: str = Field(description="根评论ID")
    comment_id: str = Field(description="评论ID")
    content: str = Field(description="评论内容")
    user_id: str = Field(description="评论用户ID")
    nickname: str = Field(description="评论用户昵称")
    time: str = Field(description="评论时间")
